import {
  CoolController,
  BaseController,
  CoolTag,
  CoolUrlTag,
  TagTypes,
} from '@cool-midway/core';
import { Provide, Body, Inject, Post, Get, Query } from '@midwayjs/decorator';
import { WallpaperImageInfoEntity } from '../../entity/image_info'; 
import { WallpaperImageInfoService } from '../../service/image_info'; 

/**
 * wallpaper模块-图片信息
 */
@Provide()
@CoolController({ description: '开放接口' })
@CoolUrlTag()
@CoolController({
  api: ['list', 'page'],
  entity: WallpaperImageInfoEntity,
  service: WallpaperImageInfoService,
  pageQueryOp: {
    keyWordLikeFields: ['image', 'path'],
    fieldEq: ['category', 'status'],
  }
})
export class AdminWallpaperImageInfoController extends BaseController {
    @Inject()
    wallpaperImageInfoService: WallpaperImageInfoService;
    
    @CoolTag(TagTypes.IGNORE_TOKEN)
    @Get('/imagesByCategory', { summary: '根据分类获取图片信息' })
    async imagesByCategory(@Query('category') category: string) {
        return this.ok(await this.wallpaperImageInfoService.getImagesByCategory(category));
    }
}
